﻿using System;
using System.Net;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Documents;
using System.Windows.Ink;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Animation;
using System.Windows.Shapes;
using System.Data.Linq;
using System.Data.Linq.Mapping;
using System.ComponentModel;

namespace SMSHelper.Data
{
    public class NumberDataContext : DataContext
    {
        public NumberDataContext(string connectionString)
            : base(connectionString)
        { }

        public Table<PhoneNumberInfo> PhoneNumbers;
    }

    [Table]
    public class PhoneNumberInfo : INotifyPropertyChanged
    {
        private int _numberID;

        [Column(IsPrimaryKey = true, DbType = "INT NOT NULL Identity", IsDbGenerated = true, CanBeNull = false, AutoSync = AutoSync.OnInsert)]
        public int NumberID
        {
            get { return _numberID; }
            set { _numberID = value; }
        }

        private string _personName;
        [Column]
        public string PersonName
        {
            get { return _personName; }
            set { _personName = value; }
        }

        private string _phoneNumber;
        [Column]
        public string PhoneNumber
        {
            get { return _phoneNumber; }
            set { _phoneNumber = value; }
        }

        private string _groupTitle;
        [Column]
        public string GroupTitle
        {
            get { return _groupTitle; }
            set { _groupTitle = value; }
        }

        private bool _isChecked;
        public bool IsChecked
        {
            get { return _isChecked; }
            set
            {
                if (_isChecked != value)
                {
                    _isChecked = value;
                    NotifyPropertyChanged("IsChecked");
                }
            }
        }

        void NotifyPropertyChanged(string propertyName)
        {
            if (PropertyChanged != null)
                PropertyChanged(this, new PropertyChangedEventArgs(propertyName));
        }

        public event PropertyChangedEventHandler PropertyChanged;
    }
}
